package ocrs.server.registeringSystem;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class CoursePlusCharacter 
{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key theKey;
	
	@Persistent
    private Course theCourse;
	
	@Persistent
    private char theChar;
    
    public CoursePlusCharacter()
    {
    	theCourse = new Course();
    	theChar = ' ';
    } // end of default constructor()
    
    public CoursePlusCharacter(Course theCourse, char theChar)
    {
    	this.theCourse = theCourse;
    	this.theChar = theChar;
    } // end of constructor()
    
    
    
    /** 
     * Name: getTheKey <br><br>
     * An accessor method that retrieves the the key for the object in the
     * Google datastore.
     * <br><br>
     * Precondition: None <br>
     * Postcondition: Returns the key. <br>
     * @param None
     */
    public Key getTheKey()
    {
    	return theKey;
    }
    
    public Course getTheCourse()
    {
    	return theCourse;
    } // end of getTheCourse()
    
    public char getTheChar()
    {
    	return theChar;
    } // end of getTheChar()
    
    public void setTheCourse(Course theCourse)
    {
    	this.theCourse = theCourse;
    } // end of setTheCourse()
    
    public void setTheChar(char theChar)
    {
    	this.theChar = theChar;
    } // end of setTheChar()
    
    /*
    private String showElementsInArray()
    {
    	String theElements = "";
    	boolean foundNullElement = false;
    	
    	for(int i = 0; i < theStringArray.length && 
    	                                        foundNullElement == false; i++)
    	{	
    		if(theStringArray[i] != null)
    			theElements += theStringArray[i] + "\n";
    	
    		else
    			foundNullElement = true;
    	}
    	
    	return theElements;
    }
    */
    
    public String toString()
    {
    	return "The course: " + theCourse.getCourseName() + "\n" +
    	       "The character: " + theChar + "\n";
    } // end of toString()
    
    
    public static void main(String[] args)
    {
    	CoursePlusCharacter abc = new CoursePlusCharacter();
    	
    	
    	abc.setTheChar('1');
    	abc.setTheCourse(new Course());
    	
    	System.out.println(abc);
    }
} // end of CoursePlusCharacter()